package com.flute.icrawler.app.listener;

import com.flute.icrawler.app.entity.CrawlResult;
import com.flute.icrawler.app.util.ParameterKey;
import com.flute.icrawler.framework.autoadjust.FetchAdjuster;
import com.flute.icrawler.framework.framework.CrawlUrl;
import com.flute.icrawler.framework.framework.listener.ICrawlTaskListener;

public class AutoAdjustListenser implements ICrawlTaskListener {

	private FetchAdjuster fetchAdjuster = null;

	public AutoAdjustListenser(FetchAdjuster fetchAdjuster) {
		this.fetchAdjuster = fetchAdjuster;
	}

	@Override
	public void update(CrawlUrl url) {
		CrawlResult result = (CrawlResult) url.getResultParameter(
				ParameterKey.RESULT_CRAWL).getValue();
		fetchAdjuster.recordFetchStatus(result.getFetchStatus());
	}

}
